package edu.uwlax.cs.oayonlinestore.client.gui;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;

import edu.uwlax.cs.oayonlinestore.client.OnlinestoreRService;
import edu.uwlax.cs.oayonlinestore.client.User;
import edu.uwlax.cs.oayonlinestore.client.utils.FormTable;
import edu.uwlax.cs.oayonlinestore.client.utils.HSpacer;
import edu.uwlax.cs.oayonlinestore.client.utils.StackPage;

public class PageHome extends StackPage {

	private class LoginForm extends FormTable {
		private TextBox login = new TextBox();

		private PasswordTextBox pwd = new PasswordTextBox();

		public LoginForm() {
			super();
			addInput("Username", login);
			addInput("Password", pwd);
			addButton("Login", Store.getFrame().getShopFrame().getMain()
					.getAnchor());
		}

		public void onButtonClicked() {
			OnlinestoreRService.Util.getInstance().login(login.getText(),
					pwd.getText(), User.get());
		}

		public void onDataLoad(Object data) {
		}

	}

	public final static String STYLE_HOME = "PageHome";
	protected void create() {
		FlowPanel p = new FlowPanel();
		p.setStyleName(STYLE_HOME);
		p.add(new HTML("<br><br><center>"
				+ "<b>Welcome to QAY Online Store.</b></br>"
				+ "YOUR place to spend money.</center>"));
		p.add(new HSpacer());
		p.add(new LoginForm());
		setWidget(p);
	}

	public String getID() {
		return "Home";
	}

}
